ErLLVM is a project aiming at providing multiple backends for the HiPE compiler with the use of the LLVM Compiler Infastructure.
At the moment, ErLLVM supports only AMD64; x86 support is currently unstable due to architectural changes. Hopefully, this will be fixed soon. There is also some ongoing work for ARM.
ErLLVM will be soon available experimentally as part of version 17.0 of
Erlang/OTP (merged into master
branch as of 1st of April 2014).
System Requirements
- LLVM >= 3.4
Hello world with ErLLVM
Write an Erlang module:
-module(test). -export([hello/1]). hello(Name) -> io:format("Hello ~w!~n", [Name]).
Fire the Erlang shell:
yiannis@mosby [~/git/otp]>>= erl Erlang/OTP 17 [erts-6.0] [source-ef8c4a6] [64-bit] [smp:16:16] [async-threads:10] [hipe] [kernel-poll:false] Eshell V6.0 (abort with ^G) 1>
Compile the module to native code using the LLVM backend:
2> c(test, [native, {hipe, [to_llvm]}]). {ok,test}
Alternatively, you can first generate BEAM bytecode and then compile it to native code and load it using:
2> c(test), hipe:c(test, [to_llvm]). {ok,test}
It works!
3> test:hello(world). Hello world! ok
All wikis are supposed to have a SandBox, so this one does too.
This wiki is powered by ikiwiki.